//
//  AutoShowRouterCenter.swift
//  App_Common
//
//  Created by 蒋晨成 on 2021/12/24.
//

import Foundation
import Standard
import UICore

enum AutoShowRouterCenter {}
extension AutoShowRouterCenter: TypeName {}

extension AutoShowRouterCenter: Actable {
    static func act(values: [String: Any]) -> Bool {
        guard let showType = values["showType"] as? String,
              let patternEncodeString = values["pattern"] as? String,
              let pattern = patternEncodeString.urlDecode()
        else {
            return false
        }
        switch showType {
        case "push":
            Router.push(pattern: pattern)
        case "present":
            Router.present(pattern: pattern)
        case "addchild":
            Router.addChild(pattern: pattern)
        case "open":
            Router.open(pattern: pattern)
        default:
            return false
        }

        return true
    }

    static var routePattern: String = "/show/<string:showType>/<string:pattern>"
}
